import { Column, Entity, Index, ManyToOne, OneToMany, OneToOne } from "typeorm";
import { CommonEntity } from "~/common/entity/common.entity";
import { UserEntity } from "~/modules/user/user.entity";
import { TagEntity } from "~/modules/assess/tag/tag.entity";
import { ShareContentEntity } from "../../share/share-content.entity";

@Index(["id"])
@Entity({ name: 'access_house' })
export class HouseEntity extends CommonEntity {

	@Column({ name: 'longitude', type: "float", comment: '经度' })
	longitude: number;

	@Column({ name: 'latitude', type: "float", comment: '纬度' })
	latitude: number;

	// 户型图链接
	@Column({ name: 'layout', nullable: true, comment: '户型图' })
	url: string;

	@Column({ name: 'owner_name', nullable: true, comment: '房主姓名' })
	ownerName: string;

	// ownerBirth 日期格式设置为 YYYY-MM-DD hh:mm:ss
	@Column({ name: 'owner_birth', type: "datetime", nullable: true, comment: '房主出生日期' })
	ownerBirth: string;

	@Column({ name: 'analysis', nullable: true, comment: '分析结果' })
	analysis: string;

	@Column({ name: 'house_type', nullable: true, comment: '户型' })
	houseType: number;

	@Column({ name: 'orient', type: "int", nullable: true, comment: '房宅朝向' })
	orient: number;

	@Column({ name: 'orient_angle', type: "float", nullable: true, comment: '朝向角度' })
	orientAngle: number;

	@Column({
		name: 'real_secret',
		nullable: true,
		comment: '真诀描述'
	})
	realSecret: string;

	@ManyToOne(() => UserEntity, person => person.houses)
	owner: UserEntity;

	@OneToMany(() => TagEntity, tag => tag.house)
	tags: TagEntity[];

	/**
	 * 关联分享内容
	 */
	@OneToOne(() => ShareContentEntity, ShareContentEntity => ShareContentEntity.house)
	shareContent: ShareContentEntity; // 关联分享内容
}
